home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Alles Voor Internet / Tout Pour Internet
/
alles voor internet.iso
/
MacInternet™
/
Telnet
/
NCSA
/
tn3270 2.4d7 source
/
SPPC
/
sppcinit.c
< prev
next >
Wrap
Text File
|
1991-05-28
|
2KB
|
73 lines
#if !defined(USEDUMP)
#include "sppclib.h"
#else
#pragma load "sppcDumpFile"
#endif
#define GOODICON 128 /* success ICON resource number */
#define BADICON 129 /* failure ICON resource number */
#define DRIVERNAME "\p.SPPC" /* name of our driver */
extern pascal void ShowINIT(short iconID, short moveX);
void sppcinit()
{
DCtlHandle **utp; /* pointer to unit table */
DCtlHandle *ut; /* unit table array */
short *utsize; /* size of array */
short i, slotnum;
Handle reshandle;
OSErr rc;
short rid;
ResType rtype;
unsigned char rname[256];
/* Search the unit table for an open slot in which to install
our driver. Search backwards from the end. If no slot is
found, exit with the error icon */
utp = (DCtlHandle **)UTableBase;
ut = *utp;
utsize = (short *)UnitNtryCnt;
slotnum = 0;
for (i = (*utsize)-1; i >= 1; i--) {
if (ut[i] == 0) {
slotnum = i;
break;
}
}
if (slotnum == 0) {
ShowINIT(BADICON, -1);
return;
}
/* Attempt to load our driver */
reshandle = GetNamedResource('DRVR', DRIVERNAME);
rc = ResError();
if (rc != noErr) {
ShowINIT(BADICON, -1);
return;
}
if (reshandle == 0) {
ShowINIT(BADICON, -1);
return;
}
/* Change resource id to open slot */
GetResInfo(reshandle, &rid, &rtype, rname);
SetResInfo(reshandle, slotnum, rname);
/* Open the driver */
OpenDeskAcc(DRIVERNAME);
/* Ensure driver undisturbed */
DetachResource(reshandle);
/* Restore previous slot in file */
reshandle = GetNamedResource('DRVR', DRIVERNAME);
SetResInfo(reshandle, rid, 0);
/* Display success icon and return */
ShowINIT(GOODICON, -1);
}